package Ysfdemo;

/**
 * 关于java运算符
 */

public class Ysfdemo1 {
    public static void main(String[] args) {
        int i = 1;
        int j = 2;
        //加法运算
        int a = i + j;
        System.out.println(a);
        //减法运算
        int b = i - j;
        System.out.println(b);
        //乘法运算
        int c = i * j;
        System.out.println(c);
        //除法运算
        System.out.println(c);
        //取模运算
        int d = i % j;
        System.out.println(d);
        System.out.println("----------------------");
        //++运算
        int e = 1;
        int f = e++;
        System.out.println(f);//1
        System.out.println(e);//2

        int g = ++e;
        System.out.println(g);//3
        System.out.println(e);//3
        //++e和e++的区别。一个自增在赋值。另一个先赋值在递增
        System.out.println("-------------------");
        //--运算，其实同上
        int h = 2;
        int o = h--;
        System.out.println(j);//2
        System.out.println(h);//1

        int y = --h;
        System.out.println(y);//0
        System.out.println(h);//0

    }
}
